package com.gdwstudy.polyArr;

public class Test {
    public static void main(String[] args) {
        Person arr[] = new Person[5];
        arr[0] = new Person("tom",20);
        arr[1] = new Student("马冬梅",13,80);
        arr[2] = new Student("赵二强",18,91.5);
        arr[3] = new Teacher("jack",30,30000);
        arr[4] = new Teacher("frank",40,23000);
        for (int i = 0; i <arr.length ; i++) {
            System.out.println(arr[i].say());
            if(arr[i] instanceof Student){
                ((Student)arr[i]).study();
            }else if(arr[i] instanceof Teacher){
                ((Teacher)arr[i]).teach();
            }else if(arr[i] instanceof Person){

            }else{
                System.out.println("类型错误");
            }
        }
    }
}
